import util from './core/util.js'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import * as echarts from 'echarts' // 引入 echarts
import './core/lazy_use'
import './permission'
import './global.less' // global style
import mixin from './mixin.js'
import 'animate.css'
import '@/assets/iconfont/iconfont.css'
import distNtko from '@/api/distNtko'

// charles 三个js放一起
import authService from '@/api/authService'
import apploader from './core/apploader.js'
import { message } from 'ant-design-vue'
import PersonalSetting from '@/components/Layout/PersonalSetting'

Vue.component('PersonalSetting', PersonalSetting)
window.dp = util
window.eventBus = new Vue()
Vue.prototype.$echarts = echarts // 引入组件
// 引入Ntko
Vue.prototype.ntkofunction = distNtko

// eslint-disable-next-line no-undef
Vue.prototype.$ = $

Vue.config.productionTip = false

Vue.mixin(mixin)

window.config = window.config ? window.config : process.env

require('./mock/index.js')

message.config({
  top: `100px`,
  duration: 1
})

function renderApp () {
  window.$distApp = new Vue({
    router,
    store,
    data: {
      eventHub: new Vue()
    },
    render: h => h(App),
    created () { }
  }).$mount('#app')
}

authService.auth().then(
  async (d) => {
    await apploader.load()
    renderApp()
  },
  (e) => {
    console.error('系统认证失败！')
    console.error(e)
  }
)
